package td0.shape;

import main.Point;

public final class Sphere extends Shape3D {

	private double radius;
	private Point center;

	public Sphere(double radius, Point center) {
		super("Sphere");
		this.radius = radius;
		this.center = new Point(center.getX(), center.getY());
	}

	@Override
	public double volume() {
		return Math.pow(4d * Math.PI * radius, 3) / 3;
	}

	@Override
	public void translate(int dx, int dy) {
		center.setX(center.getX() + dx);
		center.setY(center.getY() + dy);
	}

	@Override
	public double surface() {
		return Math.pow(4d * Math.PI * radius, 2);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;

		if (obj == this)
			return true;

		if (!this.getClass().equals(obj.getClass()))
			return false;

		Sphere s = (Sphere) obj;
		return s.radius == this.radius && s.center.equals(this.center);
	}

	@Override
	public String toString() {
		return getName() + " [radius=" + radius + ", center=" + center + "]";
	}

	public double getRadius() {
		return radius;
	}

	public void setRadius(double radius) {
		this.radius = radius;
	}

	public Point getCenter() {
		return center;
	}

	public void setCenter(Point center) {
		this.center = center;
	}

}
